package com.qf.day07.work;

import java.util.Random;

import static jdk.nashorn.internal.objects.NativeMath.random;

public class Hero {
    private String name;
    private int power; //力量
    private int intellect; //智力
    private  int fast; //敏捷

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }

    public int getIntellect() {
        return intellect;
    }

    public void setIntellect(int intellect) {
        this.intellect = intellect;
    }

    public int getFast() {
        return fast;
    }

    public void setFast(int fast) {
        this.fast = fast;
    }

    public Hero() {
    }

    public Hero(String name, int power, int intellect, int fast) {
        this.name = name;
        this.power = power;
        this.intellect = intellect;
        this.fast = fast;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", power=" + power +
                ", intellect=" + intellect +
                ", fast=" + fast +
                '}';
    }

    public int unarmedAttack() {
        Random random = new Random();
        int attackUp,attackDown;
        attackUp = (int) (this.getPower() + this.getPower()*0.2);
        attackDown = (int) (this.getPower()*0.8);
        return attackDown + random.nextInt(attackUp - attackDown)+1;

    }

}
